<#include "/@inc/IDLImplFuncMacros.ftl">
<#include "/@inc/copyright.txt">
<#assign baseName = TriaGram + Prefix + LateType>
<#assign className = TriaGram + "EA" + Prefix + LateType>
<#assign intfName = TriaGram + "I"+ Prefix + LateType>
<#assign IDLName = TriaGram + "IA" + Prefix + LateType>
<@pp.renameOutputFile name=className+".cpp">
</@pp.renameOutputFile>
//==============================================================================
//
// ${className}.cpp
// Provide implementation to interface
//      ${IDLName}
//===============================================================================
//  ${Month} ${Year}  Creation: Code generated by the CAA wizard  ${Author}
//===============================================================================

// Local framework
#include "${className}.h"
#include "${intfName}.h"
#include "CATAssert.h"

#include "${TriaGram}UtlMacros.h"

// ObjectSpecsModeler framework
#include "CATISpecObject.h"
#include "CATISpecAttrKey.h"
#include "CATISpecAttrAccess.h"
#include "CATLISTV_CATISpecObject.h"

// MecModInterfaces framework
#include "CATIAHybridShapes.h"
#include "CATMecModAutoServices.h"
#include "CATAutoConversions.h"

<@CAA_INCLUDE_HEADERS Attributes />

// Tie the implementation to its interface
// ---------------------------------------
#include "TIE_${IDLName}.h"
TIE_${IDLName}( ${className});

CATImplementClass( ${className},
                   DataExtension,
                   CATBaseObject,
                   ${baseName} );
                   //${TriaGram}${Prefix}AutoUtil,

//-----------------------------------------------------------------------------
// ${className} : constructor
//-----------------------------------------------------------------------------
${className}::${className}(): CATBaseObject()//${TriaGram}${Prefix}AutoUtil()
{
}

//-----------------------------------------------------------------------------
// ${className} : destructor
//-----------------------------------------------------------------------------
${className}::~${className}()
{
}


//-----------------------------------------------------------------------------
// ${className} : put_Name
//-----------------------------------------------------------------------------
HRESULT  ${className}::put_Name(const CATBSTR & iName)
{
   HRESULT rc = E_NOTIMPL;

   return rc;
}

//-----------------------------------------------------------------------------
// ${className} : GetItem
//-----------------------------------------------------------------------------
HRESULT ${className}::GetItem(const CATBSTR & iName, CATBaseDispatch *& opiBaseOnChildObject)
{
   HRESULT rc = E_NOTIMPL;

   return rc;
}


//-----------------------------------------------------------------------------
// ${className} : Compute()
//----------------------------------------------------------------------------
HRESULT __stdcall ${className}::Compute()
{
   HRESULT rc = S_OK ;

   // Calls feature update
   CATISpecObject_var spSpecObjectOnThis = this ;
   if (NULL_var != spSpecObjectOnThis)
   {
      spSpecObjectOnThis->Update();
   }

   return rc;
}

//-----------------------------------------------------------------------------
// ${className} : AppendHybridShape()
//----------------------------------------------------------------------------
HRESULT  __stdcall ${className}::AppendHybridShape (CATIAHybridShape *ipiHybridShapeOnShape)
{
    // Depends on the feature
   return (E_FAIL);
}


HRESULT  __stdcall ${className}::get_Thickness (CATIAHybridShape * oThickness)
{
   return (E_FAIL);
}
//-----------------------------------------------------------------------------
// ${className} : get_GeometricType()
//----------------------------------------------------------------------------
HRESULT  __stdcall ${className}::get_GeometricType(CatGeometricType & oType)
{
   // Returns Unknown type, only used by sketcher objects
   oType = catGeoTypeUnknown;
   return S_OK;
}

<#list Attributes as attrib>  <#t>
<#switch attrib.type>
<#case ""><#t>
HRESULT __stdcall ${className}::${attrib.name}()
{
	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

	HRESULT rc = sp${LateType}->${attrib.name}() ;
	return rc ;
}
<#break>
<#case "tk_boolean"><#t>
<#case "tk_param_boolean">
HRESULT __stdcall ${className}::get_${attrib.name}( boolean   &  ob${attrib.name} )
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

	rc = sp${LateType}->Get${attrib.name}( ob${attrib.name} ) ;

	return rc ;
}

HRESULT __stdcall ${className}::put_${attrib.name}( boolean  ib${attrib.name} )
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

	rc = sp${LateType}->Set${attrib.name}( ib${attrib.name} ) ;

	return rc ;
}
<#break>
<#case "tk_integer"><#t>
HRESULT __stdcall ${className}::get_${attrib.name}( short   &  on${attrib.name})
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

	int n${attrib.name} = 0 ;
	rc = sp${LateType}->Get${attrib.name}( n${attrib.name} ) ;

	// cast from int to short
	on${attrib.name} = n${attrib.name} ;

	return rc ;
}

HRESULT __stdcall ${className}::put_${attrib.name}( short  in${attrib.name} )
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

	rc = sp${LateType}->Set${attrib.name}( in${attrib.name} ) ;

	return rc ;
}
<#break>
<#case "tk_double">
<#case "tk_param_angle">
<#case "tk_param_length">
<#case "tk_param_real">
HRESULT __stdcall ${className}::get_${attrib.name}( double   &  od${attrib.name})
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

	rc = sp${LateType}->Get${attrib.name}( od${attrib.name} ) ;

	return rc ;
}

HRESULT __stdcall ${className}::put_${attrib.name}( double  id${attrib.name} )
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

	rc = sp${LateType}->Set${attrib.name}( id${attrib.name} ) ;

	return rc ;
}
<#break>
<#case "tk_string"><#t>
<#case "tk_param_string">
HRESULT __stdcall ${className}::get_${attrib.name}( CATBSTR   *&  oStr${attrib.name} )
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

    CATUnicodeString str${attrib.name};
	rc = sp${LateType}->Get${attrib.name}( str${attrib.name} ) ;
	str${attrib.name}.ConvertToBSTR(oStr${attrib.name});

	return rc ;
}

HRESULT __stdcall ${className}::put_${attrib.name}( const CATBSTR   &  iStr${attrib.name} )
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

    CATUnicodeString str${attrib.name};
	str${attrib.name}.BuildFromBSTR(iStr${attrib.name});
	rc = sp${LateType}->Set${attrib.name}( str${attrib.name} ) ;

	return rc ;
}
<#break>
<#case "tk_component"><#t>
<#case "tk_specobject"><#t>
//-----------------------------------------------------------------------------
// ${className} : get_${attrib.name}()
//----------------------------------------------------------------------------
HRESULT __stdcall ${className}::get_${attrib.name}( CATIAReference *&  opSpec${attrib.name} )
{
	HRESULT rc = E_FAIL ;

	opSpec${attrib.name} = NULL ;
	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

    CATISpecObject_var spSpecOn${attrib.name};
	rc = sp${LateType}->Get${attrib.name}( spSpecOn${attrib.name} ) ;

	if( NULL_var != spSpecOn${attrib.name})
	{
		rc =  spSpecOn${attrib.name}->QueryInterface(IID_CATIAReference, (void**) &opSpec${attrib.name});
	}

	return rc ;
}

//-----------------------------------------------------------------------------
// ${className} : put_${attrib.name}()
//----------------------------------------------------------------------------
HRESULT __stdcall ${className}::put_${attrib.name}( CATIAReference  * ipSpec${attrib.name} )
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

   // Decodes the reference and converts it as a feature
   CATISpecObject_var spSpecOn${attrib.name};
   rc = ::GetSpecFromReference( ipSpec${attrib.name}, spSpecOn${attrib.name});
   if (FAILED(rc))
   {
      return rc;
   }

	rc = sp${LateType}->Set${attrib.name}( spSpecOn${attrib.name} ) ;

	return rc ;
}
<#break>
<#case "tklist_component">
<#case "tklist_specobject">
HRESULT __stdcall ${className}::Get${attrib.name}( CATSafeArrayVariant   *&  opList${attrib.name} )
{
	opList${attrib.name} = NULL ;

	HRESULT rc = S_OK ;
	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

	CATLISTV(CATISpecObject_var) listSpec${attrib.name} ;
	rc = sp${LateType}->Get${attrib.name}( listSpec${attrib.name} ) ;

	${TriaGram}${Prefix}AutoUtil::ConvertToArrayVariant( listSpec${attrib.name}, opList${attrib.name} ) ;

   return rc ;
}

HRESULT __stdcall ${className}::Set${attrib.name}( const CATSafeArrayVariant  & iList${attrib.name} )
{
	HRESULT rc = E_FAIL ;
	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

	CATLISTV(CATISpecObject_var) listSpec${attrib.name} ;
	${TriaGram}${Prefix}AutoUtil::ConvertToSpecList(iList${attrib.name}, listSpec${attrib.name}) ;

	rc = sp${LateType}->Set${attrib.name}( listSpec${attrib.name} ) ;

   return rc ;
}

HRESULT __stdcall ${className}::Add${attrib.name}( CATIAReference  * ipSpec${attrib.name} )
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

   // Decodes the reference and converts it as a feature
   CATISpecObject_var spSpecOn${attrib.name};
   rc = ::GetSpecFromReference( ipSpec${attrib.name}, spSpecOn${attrib.name});
   if (FAILED(rc))
   {
      return rc;
   }

	rc = sp${LateType}->Add${attrib.name}( spSpecOn${attrib.name}  ) ;

	return rc ;
}

HRESULT __stdcall ${className}::Remove${attrib.name}( CATIAReference   * ipSpec${attrib.name})
{
	HRESULT rc = E_FAIL ;

	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

   // Decodes the reference and converts it as a feature
   CATISpecObject_var spSpecOn${attrib.name};
   if(ipSpec${attrib.name})
   {
	   rc = ::GetSpecFromReference( ipSpec${attrib.name}, spSpecOn${attrib.name});
	   if (FAILED(rc))
	   {
		  return rc;
	   }
   }

    // NULL_var is valid input to Remove${attrib.name}
	rc = sp${LateType}->Remove${attrib.name}( spSpecOn${attrib.name} ) ;

	return rc ;
}
<#break>
<#case "tklist_integer">
<#case "tklist_double">
<#case "tklist_string">
HRESULT __stdcall ${className}::Get${attrib.name}( CATSafeArrayVariant   *&  opList${attrib.name} )
{
	opList${attrib.name} = NULL ;

	HRESULT rc = S_OK ;
	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

<#switch attrib.type>
<#case "tklist_integer">
	CATListOfInt list${attrib.name} ; <#break>
<#case "tklist_double">
	CATListOfDouble list${attrib.name} ; <#break>
<#case "tklist_string">
	CATListOfCATUnicodeString list${attrib.name} ; <#break>
</#switch>
	rc = sp${LateType}->Get${attrib.name}( list${attrib.name} ) ;

	// TBD : Not yet implemented !!!!
	//ConvertToArrayVariant( list${attrib.name}, opList${attrib.name} ) ;

   return rc ;
}

HRESULT __stdcall ${className}::Set${attrib.name}( const CATSafeArrayVariant  & iList${attrib.name} )
{
	HRESULT rc = E_FAIL ;
	${intfName}_var sp${LateType} = this ;
	CATAssert(NULL_var != sp${LateType}) ;

<#switch attrib.type>
<#case "tklist_integer">
	CATListOfInt list${attrib.name} ; <#break>
<#case "tklist_double">
	CATListOfDouble list${attrib.name} ; <#break>
<#case "tklist_string">
	CATListOfCATUnicodeString list${attrib.name} ; <#break>
</#switch>
	// TBD : Not yet implemented !!!!
	//ConvertToSpecList(iList${attrib.name}, list${attrib.name}) ;

	rc = sp${LateType}->Set${attrib.name}( list${attrib.name} ) ;

   return rc ;
}

<#break>
</#switch>
</#list>

